import java.util.HashMap;
import java.util.Map;

class Solution {
    public int coinChange(int[] coins, int amount) {
        int n = amount;
        int m = coins.length;
        long[] f = new long[n + 1];
        String s="";
        Map<Integer, Integer> map = new HashMap<>();
        
        f[0] = 0;
        for (int i = 1; i <= n; i++) {
            f[i] = Integer.MAX_VALUE;
        }
        for (int i = 1; i <= n; i++) {
            for (int coin : coins) {
                if (coin <= i) {
                    f[i] = Math.min(f[i], f[i - coin] + 1);
                }
            }
        }
        return f[n] == Integer.MAX_VALUE ? -1 : (int) f[n];
    }
    public static void main(String[] args) {
        int[] coins = {2};
        int amount = 3;
        Solution solution = new Solution();
        int res = solution.coinChange(coins, amount);
        System.out.println(res);
    }
}